/**
 * 定义应用路由
 */
import React from 'react';
import {HashRouter as Router, Switch, Route, Redirect} from 'react-router-dom';
import path from 'path';
import store from './store';
import {Provider} from 'react-redux';
import routes from '@/routerConfig';
import Home from '@/pages/Home';
import UnityLoadProgress from './pages/Home/components/UnityLoadProgress';

const RouteItem = (props) => {
    const {redirect, path: routePath, component, key} = props;
    if (redirect) {
        return (
            <Redirect
                exact
                key={key}
                from={routePath}
                to={redirect}
            />
        );
    }
    return (
        <Route
            key={key}
            component={component}
            path={routePath}
        />
    );
};

const router = () => {
    return (
        <Provider store={store}>
            <Router>
                <Switch>
                    <Route exact path="/" component = {Home}></Route>
                    <Route path="/index" component = {Home}></Route>
                    <Route path="/unity" component = {UnityLoadProgress}></Route>
                </Switch>
            </Router>
        </Provider>
    );
};

export default router;
